/*****************************************************************************/
/* File: Picture.h															 */
/* Author: rszulgo                                                           */
/*                                                                           */
/* Description:																 */
/* A picture is manipulated directly by the end user (instead of			 */
/* the texture). The main difference between a picture and a texture		 */
/* is that the texture can contain multiple pictures (it is the				 */
/* complete file). 															 */
/*****************************************************************************/
#pragma once

#include "Texture.h"
#include "Rectangle.h"
#include "SmartPtr.h"

class CPicture;

// Typedef of a CPicture class that is wrapped inside a smart 
// pointer. 
typedef CSmartPtr<CPicture> TPicturePtr;


class CPicture
{
public:
	// Blit the image at the specified location
	void BlitPicture(int iXOffset=0, int iYOffset=0) const;
	// Blit a part of the image at the specified location.
	void BlitPicturePart(int iXOffset, int iYOffset, const TRectanglei& part);

	// Returns the texture that this image is using. 
	CTexture* GetTexture() const  { return m_pTexture; }

	// Helper functions to create an new picture. A smart pointer 
	// holding the new picture is returned. strFileName is the 
	// name of the file containing the texture and textCoord is 
	// the rectangle in this texture which contains the picture.
	static TPicturePtr CreatePicture(const std::string& strFileName);
	static TPicturePtr CreatePicture(const std::string& strFileName, 
								 const TRectanglei& textCoord);

	~CPicture();

protected:
	// Protected constructors to avoid to be able to create a 
	// CPicture instance directly. 
	CPicture(const std::string& strFileName);
	CPicture(const std::string& strFileName, const TRectanglei& textCoord);

private:
	// The texture from which this picture is part of.
	CTexture*   m_pTexture;
	// The rectangle that specifies the position of the picture 
	// in the full texture.
	TRectanglei  m_rectTextCoord;
};